<?php
use  yii\helpers\Url;
use  yii\helpers\Html;
$link = \backend\modules\models\setting\LinkCategory::find()->all();
?>
<div class="col-md-4">
    <div class="card mb-4 shadow-sm links-box">
        <div class="card-body">
            <div class="link-title">友情链接</div>
            <div class="select-wrap">
                <?php if ($link) { ?>
                    <?php foreach ($link as $one => $first) : ?>
                        <div class="dropdown">
                            <button class="btn btn-light dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                <?= Html::encode($first->category) ?>
                            </button>
                            <?php if ($first->link) { ?>
                                <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
                                    <?php foreach ($first->link as $two => $second) : ?>
                                        <a class="dropdown-item" href="<?= Html::encode($second->href) ?>" target="_blank"><?= Html::encode($second->name) ?></a>
                                    <?php endforeach ?>
                                </div>
                            <?php } ?>
                        </div>
                    <?php endforeach ?>
                    </ul>
                <?php } ?>
            </div>
        </div>
    </div>
</div>